<template>
  <a-card :bordered="false" style="position: relative;">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper search-box-cuesList" style="margin-bottom:10px">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">

          <a-col :xl="6" :lg="6" :md="6" :sm="24">
            <a-form-item>
              <a-input placeholder="输入申请人姓名模糊查询" v-model="queryParam.realName"></a-input>
            </a-form-item>
          </a-col>

          <a-col :xl="4" :lg="6" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search" title="搜索" shape="circle"></a-button>
              <a-button
                type="primary"
                @click="searchReset"
                icon="reload"
                style="margin-left: 8px"
                title="重置"
                shape="circle"></a-button>

            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>

    <a-table
      ref="table"
      size="middle"
      rowKey="id"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
      :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
      @change="handleTableChange"
    >
      <span slot="action" slot-scope="text, record" >
        <a @click="handleEdit(record)" title="审核"><a-icon type="audit" /></a>
      </span>
      <span slot="status" slot-scope="text, record">
        <span v-if="record.applyStatus == '0'">待审核</span>
        <span v-if="record.applyStatus == '1'">已通过</span>
        <span v-if="record.applyStatus == '2'">未通过</span>
      </span>
    </a-table>
    <a-drawer
      title="审核"
      :width="1000"
      :visible="visible"
      :confirmLoading="confirmLoading"
      @close="onClose"
    >
      <!-- 选题信息 -->
      <div>
        <a-row>
          <a-col :span="12" class="check_list_item">
            <span>申请人姓名:</span>
            <span>{{ record.realName }}</span>
          </a-col>
          <a-col :span="12" class="check_list_item">
            <span>用户手机号:</span>
            <span>{{ record.userMobile }}</span>
          </a-col>

        </a-row>
        <a-row>
          <a-col :span="12" class="check_list_item">
            <span>申请人身份证:</span>
            <span> {{ record.idCard }}</span>
          </a-col>
          <a-col :span="12" class="check_list_item">
            <span>申请时间:</span>
            <span> {{ record.applyTime }}</span>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" class="check_list_item">
            <div>身份证正面照片:</div>
            <div class="check_detail_image">
              <img :src="record.idCardImgFront">
            </div>
          </a-col>
          <a-col :span="12" class="check_list_item">
            <div>身份证反面照片:</div>
            <div class="check_detail_image">
              <img :src="record.idCardImgBack">
            </div>
          </a-col>
        </a-row>
        <a-row>

        </a-row>
        <a-row>
          <a-col :span="12" class="check_list_item">
            <div>手持身份证照片:</div>
            <div class="check_detail_image">
              <img :src="record.idCardImgHolding">
            </div>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" class="check_list_item" style="margin-top: 50px;">
            <span>申请通过:</span>
            <span class="check_detail_image">
              <a-radio-group name="radioGroup" :default-value="1" v-model="tempStatus">
                <a-radio :value="1">
                  通过
                </a-radio>
                <a-radio :value="2">
                  不通过
                </a-radio>
              </a-radio-group>
            </span>
          </a-col>
        </a-row>
        <a-row v-if="tempStatus == 2">
          <a-col :span="12" class="check_list_item">
            <span>申请拒绝备注:</span>
            <span class="check_detail_image">
              <a-textarea placeholder="请输入拒绝原因" :rows="4" v-model="record.applyRefuseRemark"/>
            </span>
          </a-col>
        </a-row>
      </div>
      <div>
        <a-button @click="submit">确定</a-button>
      </div>
    </a-drawer>
  </a-card>
</template>

<script>
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { getAction, putAction } from '@/api/manage'
  import JInput from '@/components/jeecg/JInput'

  export default {
    name: 'LiveList',
    mixins: [JeecgListMixin],
    components: {JInput},
    data () {
      return {
        description: '直播审核管理页面',
        record: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 }
        },
        data: [],
        // 表头
        columns: [
          {
            title: '申请人名称', // 1、文章2、视频 3、音频  4、H5
            align: 'center',
            dataIndex: 'realName'
          },
          {
            title: '申请人手机号', // 1、文章2、视频 3、音频  4、H5
            align: 'center',
            dataIndex: 'userMobile'
          },
          {
            title: '申请时间',
            align: 'center',
            dataIndex: 'applyTime'

          },
          {
            title: '状态',
            align: 'center',
            dataIndex: 'status',
            scopedSlots: { customRender: 'status' }
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: 'audit/live/liveApply/list',
          activityList: '/content/conActivityInfo/lis',
          liveList: '/live/liveApply/list',
          contentList: '/content/conContentRemark/list'
          // importExcelUrl: "audit/c onContentInfo/importExcel",
        },
        visible: false,
        confirmLoading: false,
        tempStatus: 1
      }
    },

    mounted: function () {
      this.getAllList()
    },
    methods: {
      submit () {
        if (this.tempStatus == 1) {
          this.adopt()
        } else {
          this.reject()
        }
      },
      reject () {
        putAction('audit/live/liveApply/auditLiveApplyReject', this.record).then(res => {
          if (res.success) {
            this.visible = false
            this.searchReset()
          }
        })
      },
      adopt () {
        const params = {id:this.record.id,
          userId:this.record.userId,
          expiresStartTime:this.record.expiresStartTime,
          expiresEndTime:this.record.expiresEndTime,
          isNeverExpires:this.record.isNeverExpires}
        putAction('audit/live/liveApply/auditLiveApplyRelease',params).then(res => {
          if (res.success) {
            this.visible = false
            this.searchReset()
          }
        })
      },
      handleEdit (record) {
        this.record = record
        this.tempStatus = this.record.applyStatus
        // if(this.record.applyStatus == 0){
        // 	this.record.applyStatus = 1
        // }
        this.visible = true
      },
      onClose () {
        this.visible = false
      },
      close () {
        this.visibleupdate = false
      },
      updateData () {
        this.visible = true
      },
      getAllList () {
        var param = {
          pageNo: 1,
          pageSize: 100
        }
        getAction('/audit/live/liveApply/list', param).then(res => {
          if (res.success) {
            this.data = res.result.records
            this.data.forEach(item => {
              if (item.applyStatus === 0) {
                item.status = '申请中'
              } else if (item.applyStatus === 1) {
                item.status = '审核通过'
              } else if (item.applyStatus === 2) {
                item.status = '审核不通过'
              } else if (item.applyStatus === 3) {
                item.status = '重新申请中'
              }
            })
          }
        })
      },
      getStatusParse (value) {
        if (value == 1) {
          return '是'
        } else {
          return '否'
        }
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
  .check_list_item{
    padding: 5px;
  }
  .check_detail_image{
    width: 300px;
    height: 200px;
    padding: 10px 0px;
  }
  .check_detail_image img{
    width: 100%;;
    height: 100%;;
  }
</style>
